<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
            "http://www.w3.org/TR/REC-html40/loose.dtd">
<HTML>
<HEAD>



<META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<META name="GENERATOR" content="hevea 1.08">
<LINK rel="stylesheet" type="text/css" href="tutorial.css">
<TITLE>
Basic Suspension Facility
</TITLE>
</HEAD>
<BODY >
<A HREF="tutorial102.html"><IMG SRC ="previous_motif.gif" ALT="Previous"></A>
<A HREF="tutorial098.html"><IMG SRC ="contents_motif.gif" ALT="Up"></A>
<A HREF="tutorial104.html"><IMG SRC ="next_motif.gif" ALT="Next"></A>
<HR>

<H2 CLASS="section"><A NAME="htoc207">14.5</A>&nbsp;&nbsp;Basic Suspension Facility</H2>

For the more complex constraint behaviours (beyond those waiting for
instantiations), we need to employ lower-level primitives of the ECL<SUP><I>i</I></SUP>PS<SUP><I>e</I></SUP>
kernel (suspensions and priorities).
<A NAME="@default372"></A>
<A NAME="@default373"></A>
If we want to add a new constraint to an existing solver, we also
need to use the lower-level interface that the particular solver
provides.<BR>
<BR>
Apart from the delay clauses used above,
ECL<SUP><I>i</I></SUP>PS<SUP><I>e</I></SUP> also provides a more powerful (though less declarative) way of
causing a goal to delay.
The following is another implementation of the constraint checking behaviour,
this time using the suspend/3 built-in predicate to create a delayed goal for
<A NAME="@default374"></A>
capacity/2:

	<TABLE CELLPADDING=10>
<TR><TD BGCOLOR="#CCCCFF">
	<BLOCKQUOTE CLASS="quote"><PRE>
capacity(T,N) :- (var(T);var(N)), !,
        suspend(capacity(T,N), 0, [T,N]-&gt;inst).
capacity(1, N) :- N&gt;=0.0, N=&lt;350.0.
capacity(2, N) :- N&gt;=0.0, N=&lt;180.0.
capacity(3, N) :- N&gt;=0.0, N=&lt;50.0.
</PRE></BLOCKQUOTE></TD>
</TR></TABLE>

	<BLOCKQUOTE CLASS="figure"><DIV CLASS="center"><HR WIDTH="80%" SIZE=2></DIV>
	<DIV CLASS="center">
	<TABLE CELLPADDING=10>
<TR><TD BGCOLOR="#DB9370">
	
<DL CLASS="description" COMPACT=compact><DT CLASS="dt-description">
<B>suspend(Goal, Priority, Triggers)</B><DD CLASS="dd-description"> 
	<A NAME="@default375"></A>
 Creates Goal as a delayed goal with a given waking priority and
 triggering conditions.
 Triggers is a list of Variables-&gt;Conditions terms, specifying
 under which conditions the goal will be woken up.
 The priority specifies with which priority the goal will be scheduled
 after it has been triggered.
 A priority of 0 selects the default for the predicate.
 Otherwise, valid priorities range are from
 1 (most urgent, reserved for debugging purposes) to 12 (least urgent).
</DL>
Some valid triggers:
<A NAME="@default376"></A>
<DL CLASS="description" COMPACT=compact><DT CLASS="dt-description">
<B>X-&gt;inst</B><DD CLASS="dd-description"> wake when the variable becomes instantiated (most specific)
<DT CLASS="dt-description"><B>X-&gt;constrained</B><DD CLASS="dd-description"> wake when the variable becomes constrained somehow
 (most general)
<DT CLASS="dt-description"><B>X-&gt;ic:min</B><DD CLASS="dd-description"> wake when the lower bound of an ic-variable changes
<DT CLASS="dt-description"><B>X-&gt;ic:max</B><DD CLASS="dd-description"> wake when the upper bound of an ic-variable changes
<DT CLASS="dt-description"><B>X-&gt;ic:hole</B><DD CLASS="dd-description"> wake an internal domain value gets removed
</DL>

	</TD>
</TR></TABLE>
	</DIV>
	<BR>
<BR>
<DIV CLASS="center">Figure 14.3: The Basic Suspension Facilities</DIV><BR>
<BR>

	<DIV CLASS="center"><HR WIDTH="80%" SIZE=2></DIV></BLOCKQUOTE>
<HR>
<A HREF="tutorial102.html"><IMG SRC ="previous_motif.gif" ALT="Previous"></A>
<A HREF="tutorial098.html"><IMG SRC ="contents_motif.gif" ALT="Up"></A>
<A HREF="tutorial104.html"><IMG SRC ="next_motif.gif" ALT="Next"></A>
</BODY>
</HTML>
